﻿namespace EFS.RC.ConversationBrowser.Tools.Conversation
{
	public class Event : EFS.RC.ConversationBrowser.Tools.Search.Result
	{
		public Event()
		{
		}

		/// Property EventType: Get, Set
		public System.String EventType { get; set; }

		/// Property Ended: Get, Set
		public System.DateTime? Ended { get; set; }

		/// Property DurationFromBeginningTicks: Get
		public System.Int64? DurationFromBeginningTicks { get; set; }

		/// Property OccurredFromBeginningTS: Get
		public System.TimeSpan? OccurredFromBeginningTS
		{
			get
			{
				System.TimeSpan? durationTS = DurationTS;
				if (!durationTS.HasValue || !DurationFromBeginningTicks.HasValue)
				{
					return null;
				}

				// ok
				return new System.TimeSpan(DurationFromBeginningTicks.Value) - durationTS;
			}
		}

		/// Property OccurredFromBeginningDT: Get
		public System.DateTime? OccurredFromBeginningDT
		{
			get
			{
				System.TimeSpan? occurredFromBeginningTS = OccurredFromBeginningTS;
				if (!occurredFromBeginningTS.HasValue)
				{
					return null;
				}

				// ok
				return new System.DateTime(occurredFromBeginningTS.Value.Ticks);
			}
		}

		/// Property DurationTS: Get
		public System.TimeSpan? DurationTS
		{
			get
			{
				if (!Occurred.HasValue || !Ended.HasValue)
				{
					return null;
				}

				// ok
				return Ended.Value - Occurred.Value;
			}
		}

		/// Property DurationDT: Get
		public System.DateTime? DurationDT
		{
			get
			{
				System.TimeSpan? durationTS = DurationTS;
				if (durationTS.HasValue)
				{
					return new System.DateTime(durationTS.Value.Ticks);
				}

				// none
				return null;
			}
		}
	}

}